// import "whatwg-fetch";
// import credentialsFetch from "./fetch";
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import WujieVue from "wujie-vue3";
import lifecycles from "./lifecycle";

const { setupApp, preloadApp } = WujieVue;

createApp(App).use(WujieVue).use(store);

const degrade =
  window.localStorage.getItem("degrade") === "true" ||
  !window.Proxy ||
  !window.CustomElementRegistry;
const props = {
  jump: (name: string) => {
    router.push({ name });
  },
};

//设置子应用默认参数
setupApp({
  name: "test1",
  url: "//localhost:3000/",
  exec: true,
  sync: true,
  alive: true,
  props,
  // fetch: credentialsFetch,
  degrade,
  ...lifecycles,
});

if (window.localStorage.getItem("preload") !== "false") {
  if (window.Proxy) {
    //预加载
    preloadApp({
      name: "test1",
      url: "",
    });
  }
}

createApp(App).use(router).mount("#app");
